﻿namespace Digitalmes.Domain.Mes;

/// <summary>
/// 手动返工单
/// </summary>
[SugarTable("rework_manual_doc", "产品手动返工单")]
public sealed class ReworkManualDoc : EntityBase
{
    /// <summary>
    /// 产品返工单据号
    /// </summary>
    [NotNull]
    public string? Doc { get; set; }

    /// <summary>
    /// SN
    /// </summary>
    [NotNull]
    [SugarColumn(ColumnDescription = "SN", Length = 64)]
    public string? Sn { get; set; }

    /// <summary>
    /// 产线Id
    /// </summary>
    public long LineId { get; set; }

    /// <summary>
    /// 产线编号
    /// </summary>
    [NotNull]
    [SugarColumn(ColumnDescription = "产线编号", Length = 32)]
    public string? LineCode { get; set; }

    /// <summary>
    /// 返工单状态
    /// </summary>
    public ReworkStatusEnum Status { get; set; } = ReworkStatusEnum.Created;

    /// <summary>
    /// 返工人员
    /// </summary>
    [SugarColumn(ColumnDescription = "返工人员", Length = 64)]
    public string? Operator { get; set; }

    /// <summary>
    /// 返工完成时间
    /// </summary>
    public DateTime? CompletedTime { get; set; }

    /// <summary>
    /// 返修结果（OK/NG）
    /// </summary>
    /// <remarks>注：返工结果都为 OK</remarks>
    public ReworkResultEnum Result { get; set; } = ReworkResultEnum.OK;

    /// <summary>
    /// 针对离线返工，返工的产线编号
    /// </summary>
    public string? ReworkLineCode { get; set; }

    /// <summary>
    /// 针对离线返工，返工的工位编号
    /// </summary>
    public string? ReworkOpCode { get; set; }

    /// <summary>
    /// 备注
    /// </summary>
    [SugarColumn(ColumnDescription = "备注", Length = 512)]
    public string? Remark { get; set; }

    /// <summary>
    /// 明细项集合。
    /// </summary>
    [Navigate(NavigateType.OneToMany, nameof(ReworkManualDocLine.DocId))]
    public List<ReworkManualDocLine>? DocLines { get; set; }
}
